﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR67Request", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR67Request))]
    public class RR67RequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR67Request clazz;
        
        public RR67RequestSerializer(IRR67Request clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("cAlgKpv");
            if (clazz.CAlgKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CAlgKpv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CAlgKpv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cAlgKell");
            if (clazz.CAlgKell!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CAlgKell))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CAlgKell");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cLoppKpv");
            if (clazz.CLoppKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CLoppKpv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CLoppKpv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cLoppKell");
            if (clazz.CLoppKell!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CLoppKell))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CLoppKell");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("cMuutused");
            if (clazz.CMuutused!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.CMuutused))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : CMuutused");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="cAlgKpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR67Request>cAlgKpv");
                }
                clazz.CAlgKpv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cAlgKpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR67Request>cAlgKpv", Reader.LocalName);
            }
            if (Reader.LocalName=="cAlgKell") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR67Request>cAlgKell");
                }
                clazz.CAlgKell = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cAlgKell")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR67Request>cAlgKell", Reader.LocalName);
            }
            if (Reader.LocalName=="cLoppKpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR67Request>cLoppKpv");
                }
                clazz.CLoppKpv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cLoppKpv")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR67Request>cLoppKpv", Reader.LocalName);
            }
            if (Reader.LocalName=="cLoppKell") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR67Request>cLoppKell");
                }
                clazz.CLoppKell = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cLoppKell")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR67Request>cLoppKell", Reader.LocalName);
            }
            if (Reader.LocalName=="cMuutused") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR67Request>cMuutused");
                }
                clazz.CMuutused = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("cMuutused")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR67Request>cMuutused", Reader.LocalName);
            }
        }
    }
}
